﻿/*
This script was created by Visual Studio on 19-9-2011 at 13:39.
Run this script on [SOGETI-2184.Pets] to make it the same as [SOGETI-2184.University].
This script performs its actions in the following order:
1. Disable foreign-key constraints.
2. Perform DELETE commands. 
3. Perform UPDATE commands.
4. Perform INSERT commands.
5. Re-enable foreign-key constraints.
Please back up your target database before running this script.
*/
SET NUMERIC_ROUNDABORT OFF
GO
SET XACT_ABORT, ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
use University
/*Pointer used for text / image updates. This might not be needed, but is declared here just in case*/
DECLARE @pv binary(16)
BEGIN TRANSACTION
ALTER TABLE [dbo].[InstructorSet] DROP CONSTRAINT [FK_DepartmentInstructor]
ALTER TABLE [dbo].[CourseSet] DROP CONSTRAINT [FK_DepartmentCourse]
ALTER TABLE [dbo].[EnrollmentSet] DROP CONSTRAINT [FK_SectionEnrollment]
ALTER TABLE [dbo].[EnrollmentSet] DROP CONSTRAINT [FK_StudentEnrollment]
ALTER TABLE [dbo].[SectionSet] DROP CONSTRAINT [FK_CourseSection]
ALTER TABLE [dbo].[SectionSet] DROP CONSTRAINT [FK_InstructorSection]
ALTER TABLE [dbo].[SectionSet] DROP CONSTRAINT [FK_LocationSection]
SET IDENTITY_INSERT [dbo].[LocationSet] ON
INSERT INTO [dbo].[LocationSet] ([Id], [Name], [Country]) VALUES (1, N'Neverland', N'US')
SET IDENTITY_INSERT [dbo].[LocationSet] OFF
SET IDENTITY_INSERT [dbo].[SectionSet] ON
INSERT INTO [dbo].[SectionSet] ([Id], [Term], [Building], [Room], [Time], [Location_Id], [Course_Id], [Instructor_Id]) VALUES (4, N'1', N'Home', N'Bedroom', N'22:00', 1, 1, 2)
SET IDENTITY_INSERT [dbo].[SectionSet] OFF
SET IDENTITY_INSERT [dbo].[EnrollmentSet] ON
INSERT INTO [dbo].[EnrollmentSet] ([Id], [GradeCode], [Section_Id], [Student_Id]) VALUES (1, N'F', 4, 1)
INSERT INTO [dbo].[EnrollmentSet] ([Id], [GradeCode], [Section_Id], [Student_Id]) VALUES (2, N'A', 4, 2)
SET IDENTITY_INSERT [dbo].[EnrollmentSet] OFF
SET IDENTITY_INSERT [dbo].[DepartmentSet] ON
INSERT INTO [dbo].[DepartmentSet] ([Id], [Name]) VALUES (1, N'Writers')
SET IDENTITY_INSERT [dbo].[DepartmentSet] OFF
SET IDENTITY_INSERT [dbo].[CourseSet] ON
INSERT INTO [dbo].[CourseSet] ([Id], [Title], [Credits], [Description], [Department_Id]) VALUES (1, N'Flying', 1, N'Flying 101', 1)
SET IDENTITY_INSERT [dbo].[CourseSet] OFF
SET IDENTITY_INSERT [dbo].[InstructorSet] ON
INSERT INTO [dbo].[InstructorSet] ([Id], [FirstName], [LastName], [Department_Id]) VALUES (2, N'J.M.', N'Barrie', 1)
SET IDENTITY_INSERT [dbo].[InstructorSet] OFF
SET IDENTITY_INSERT [dbo].[StudentSet] ON
INSERT INTO [dbo].[StudentSet] ([Id], [FirstName], [LastName]) VALUES (1, N'Peter', N'Pan')
INSERT INTO [dbo].[StudentSet] ([Id], [FirstName], [LastName]) VALUES (2, N'Captain', N'Hook')
SET IDENTITY_INSERT [dbo].[StudentSet] OFF
ALTER TABLE [dbo].[InstructorSet] ADD CONSTRAINT [FK_DepartmentInstructor] FOREIGN KEY ([Department_Id]) REFERENCES [dbo].[DepartmentSet] ([Id])
ALTER TABLE [dbo].[CourseSet] ADD CONSTRAINT [FK_DepartmentCourse] FOREIGN KEY ([Department_Id]) REFERENCES [dbo].[DepartmentSet] ([Id])
ALTER TABLE [dbo].[EnrollmentSet] ADD CONSTRAINT [FK_SectionEnrollment] FOREIGN KEY ([Section_Id]) REFERENCES [dbo].[SectionSet] ([Id])
ALTER TABLE [dbo].[EnrollmentSet] ADD CONSTRAINT [FK_StudentEnrollment] FOREIGN KEY ([Student_Id]) REFERENCES [dbo].[StudentSet] ([Id])
ALTER TABLE [dbo].[SectionSet] ADD CONSTRAINT [FK_CourseSection] FOREIGN KEY ([Course_Id]) REFERENCES [dbo].[CourseSet] ([Id])
ALTER TABLE [dbo].[SectionSet] ADD CONSTRAINT [FK_InstructorSection] FOREIGN KEY ([Instructor_Id]) REFERENCES [dbo].[InstructorSet] ([Id])
ALTER TABLE [dbo].[SectionSet] ADD CONSTRAINT [FK_LocationSection] FOREIGN KEY ([Location_Id]) REFERENCES [dbo].[LocationSet] ([Id])
COMMIT TRANSACTION
